from django.db import models
from datetime import datetime


class Spit(models.Model):
    """吐槽"""
    content = models.CharField(null=True, max_length=500)  # 吐槽内容
    publishtime = models.DateTimeField(null=True, default=datetime.utcnow)  # 发布日期
    userid = models.IntegerField(null=True)  # 发布人ID
    nickname = models.CharField(null=True, max_length=20)  # 发布人昵称
    visits = models.IntegerField(default=0)  # 浏览量
    thumbup = models.IntegerField(default=0)  # 点赞数
    comment = models.IntegerField(default=0)  # 回复数
    avatar = models.CharField(null=True, max_length=500)  # 用户的头像
    parent = models.ForeignKey('self', on_delete=models.SET_NULL, related_name='subs', null=True, blank=True,
                               )  # 上级ID
    collected = models.BooleanField(default=False)  # 是否收藏
    hasthumbup = models.BooleanField(default=False)  # 是否点赞

    class Meta:
        db_table = 'tb_spit'
        verbose_name = '吐槽'
        verbose_name_plural = verbose_name

# class Spit(models.Model):
#     """吐槽"""
#     content = models.CharField(null=True, max_length=500)  # 吐槽内容
#     publishtime = models.DateTimeField(null=True, default=datetime.utcnow)  # 发布日期
#     userid = models.IntegerField(null=True)  # 发布人ID
#     nickname = models.CharField(null=True, max_length=20)  # 发布人昵称
#     visits = models.IntegerField(default=0)  # 浏览量
#     thumbup = models.IntegerField(default=0)  # 点赞数
#     comment = models.IntegerField(default=0)  # 回复数
#     avatar = models.CharField(null=True, max_length=500)  # 用户的头像
#     parent = models.ForeignKey('self', on_delete=models.SET_NULL, related_name='subs', null=True, blank=True,
#                                )  # 上级ID
#     collected = models.ManyToManyField(default=False)  # 是否收藏
#     hasthumbup = models.ManyToManyField(default=False)  # 是否点赞
#
#     class Meta:
#         db_table = 'tb_spit'
#         verbose_name = '吐槽'
#         verbose_name_plural = verbose_name
